package com.xcode.luckymoney;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;

/**
 * @author com.ymy.hadoop
 * @date 2019/4/20 21:13
 */
//@RestController
@Controller
@RequestMapping("/xcode")
public class HelloController {

//    @Value("${minMoney}")
//    private BigDecimal minMoney;
//
//    @Value("${description}")
//    private String description;

    @Autowired
    private LimitConfig limitConfig;

      // @RequestMapping(value = "/hello",method = RequestMethod.GET)
      @GetMapping({"/hello","/hello2"})
      @ResponseBody
      public String say(){
//          return "Spring-boot 入门了";
//        return "minMoney:" + minMoney + "description" + description;
          return "说明: " + limitConfig.getDescription();
      }

      @GetMapping("/hi")
      public String demo(){
          return "index";
      }

      @PostMapping("/say")
      @ResponseBody
      public String demo2(){
          return "说明:" + limitConfig.getDescription();
      }

      // 兼容Post、Get方式
      @RequestMapping("/say2")
      public String demo3(){
//         return "兼容Post与Get方式 说明:" + limitConfig.getDescription();
          return "index";
      }

      @GetMapping("/say/{id}")
      @ResponseBody
      public String demo4(@PathVariable("id") Integer id){
          return "id:" + id;
      }

      @GetMapping("/say3")
      @ResponseBody
      public String demo5(@RequestParam("id2") Integer id){
          return "哈哈 id2 " + id;
      }

      @RequestMapping("/say4")
      @ResponseBody
      public String demo6(@RequestParam(value = "id",required = false,defaultValue = "10") Integer myId){
            return "myId ===> id " + myId;
      }
}
